/*
 * Package: org.grassfield.common.entity
 * FileName: User.java
 *  
 * Created by pandian on Jan 28, 2011
 */
package bean;

import org.hibernate.validator.NotEmpty;
import org.hibernate.validator.NotNull;

/**
 * The Class User.
 */
public class User implements Comparable<User> {
	private long id;
	@NotNull
	@NotEmpty
	private String userName;
	@NotNull
	@NotEmpty
	private String password;
	private String companyName;
	@NotNull
	private Team team;
	private ContactInfo contactInfo;
	private UserRole userRole;
	
	/**
	 * Gets the id.
	 * 
	 * @return the id
	 */
	public long getId() {
		return id;
	}
	
	/**
	 * Sets the id.
	 * 
	 * @param id
	 *            the new id
	 */
	public void setId(long id) {
		this.id = id;
	}
	
	/**
	 * Gets the user name.
	 * 
	 * @return the user name
	 */
	public String getUserName() {
		return userName;
	}
	
	/**
	 * Sets the user name.
	 * 
	 * @param userName
	 *            the new user name
	 */
	public void setUserName(String userName) {
		this.userName = userName;
	}
	
	/**
	 * Gets the password.
	 * 
	 * @return the password
	 */
	public String getPassword() {
		return password;
	}
	
	/**
	 * Sets the password.
	 * 
	 * @param password
	 *            the new password
	 */
	public void setPassword(String password) {
		this.password = password;
	}

	/**
	 * Gets the company name.
	 * 
	 * @return the company name
	 */
	public String getCompanyName() {
		return companyName;
	}

	/**
	 * Sets the company name.
	 * 
	 * @param companyName
	 *            the new company name
	 */
	public void setCompanyName(String companyName) {
		this.companyName = companyName;
	}

	/**
	 * Gets the team.
	 * 
	 * @return the team
	 */
	public Team getTeam() {
		return team;
	}

	/**
	 * Sets the team.
	 * 
	 * @param team
	 *            the new team
	 */
	public void setTeam(Team team) {
		this.team = team;
	}

	/**
	 * Gets the contact info.
	 * 
	 * @return the contact info
	 */
	public ContactInfo getContactInfo() {
		return contactInfo;
	}

	/**
	 * Sets the contact info.
	 * 
	 * @param contactInfo
	 *            the new contact info
	 */
	public void setContactInfo(ContactInfo contactInfo) {
		this.contactInfo = contactInfo;
	}

	/**
	 * Gets the user role.
	 * 
	 * @return the user role
	 */
	public UserRole getUserRole() {
		return userRole;
	}

	/**
	 * Sets the user role.
	 * 
	 * @param userRole
	 *            the new user role
	 */
	public void setUserRole(UserRole userRole) {
		this.userRole = userRole;
	}

	/* (non-Javadoc)
	 * @see java.lang.Object#toString()
	 */
	@Override
	public String toString() {
		return this.userName+" ["+this.team+"]";
	}

	/* (non-Javadoc)
	 * @see java.lang.Comparable#compareTo(java.lang.Object)
	 */
	@Override
	public int compareTo(User arg0) {
		User u1 = (User) arg0;
		int result = -1;
		if (u1.getId() == this.id)
			result = 0;
		if (u1.getId() > this.id)
			result = 1;
		return result;
	}

}
